<script type="text/javascript" src="<?php echo URL_JS; ?>ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="<?php echo URL_JS; ?>update_news_form.js"></script>
<script type="text/javascript" src="<?php echo URL_JS; ?>update_users_form.js"></script>
<?php

// Si le fichier de qui dÔøΩfinie les constantes n'a pas encore ÔøΩtÔøΩ appelÔøΩ on le charge
if (!defined('CONFIGURATION_FILE_LOADED'))
    include( 'includes/configuration_include.php');


include( PATH_MODELS . 'update_comment_model.php');
include( PATH_VIEWS . 'update_comment_view.php');

$bdd = model_db_connexion();
// Si l'utilisateur est deja logue
if (!empty($_SESSION['id_user'])) {
    echo'<span class="template_title">Gestion des commentaires</span>';
    
    if (isset($_POST['delete'])) {
        $id = $_POST['delete'];
        deleteComment($bdd, $id);
    }
    //On cree un champ cache qui contient la valeur des commentaires a partir desquels on doit commencer a les selectionner.
    if (isset($_GET['utilisateur']) && isset($_GET['details'])) {
        header('location:' . URL_ROOT);
    }

    //On teste si on est sur un champ d'une oeuvre 
    else {

        //On affiche les commentaires
        $reponse = selectComments($bdd, "work", 3);
        echo '<div id="comments">';
        printComments($bdd, $reponse);
        echo '</div>
                    </div>';
    }
} else {
    echo '<span class="template_span">' . LANG_NO_CONNECT . '</span>';
}
?>
<script type="text/javascript">
 function envoi_comment_delete($id){
     
                var w = $id;
                document.location.href = "<?php echo URL_ROOT . 'update-comments/delete-' ?>"+w;
                document.form2.submit();
            } 
        </script>
        <script type="text/javascript">
    
    
</script>